package com.TPNexus.dao;

import java.util.ArrayList;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

import org.hibernate.Query;
import org.hibernate.Session;

import com.TPNexus.model.CatalogItem;
import com.TPNexus.model.User;

@Named
@ApplicationScoped
public class AAADAO {
	public User userLogin(String username, String password) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		session.beginTransaction();
		User result = null;
		User query = (User) session.createQuery(
				"from User u where u.username='" + username + "'")
				.uniqueResult();
		if (query != null) {
			if(query.getPassword().equals(password))
			result = query;
		}

		session.getTransaction().commit();
		return result;
	}
}
